package com.springboot.mybatis.base.utils;

import com.springboot.mybatis.base.enums.ExceptionAbstractEnum;
import com.springboot.mybatis.base.exception.CentralException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExceptionHelper {
    private static final Logger log = LoggerFactory.getLogger(ExceptionHelper.class);

    public ExceptionHelper() {
    }

    public static CentralException build(String code, String msg) {
        log.warn("提示信息：[{}]-[{}]", code, msg);
        return new CentralException(code, msg);
    }

    public static CentralException build(ExceptionAbstractEnum e) {
        log.warn("提示信息：[{}]-[{}]", e.getCode(), e.getMessage());
        return new CentralException(e.getCode(), e.getMessage());
    }

    public static CentralException build(ExceptionAbstractEnum e, String msg) {
        msg = e.getMessage() + " - " + msg;
        log.warn("提示信息：[{}]-[{}]", e.getCode(), msg);
        return new CentralException(e.getCode(), msg);
    }
}